package graph;
import list.*;

/**
 * The Edge class represents an edge connecting two 
 * vertices, its weight and its partner edge.
 */
public class Edge {

	protected DListNode partner;
	protected VertexPair edge;
	protected int weight;

	/**
	 *  Constructs a new Edge object
	 *  
	 *  @param partner is the DListNode representing the partner edge. 
	 *  	null if this is a self edge.
	 *  @param edge is the vertex pair reprenting this edge.
	 *  @param weight is the weight of this edge.
	 *  
	 *  @return a new Edge.
	 */
	public Edge(DListNode partner, VertexPair edge, int weight) {
		this.partner = partner;
		this.edge = edge;
		this.weight = weight;
	}

	/**
	 * setPartner() sets "this" Edge's partner as partner
	 * 
	 * @param partner the new partner for "this" Edge.
	 */
	protected void setPartner(DListNode partner) {
		this.partner = partner;		
	}

	/**
	 * partner() returns the partner to "this" Edge.
	 * 
	 * @return the partner to "this" Edge.
	 */
	public DListNode partner() {
		return partner;
	}

	/**
	 * edge() returns the VertexPair to "this" Edge.
	 * 
	 * @return the VertexPair to "this" Edge.
	 */
	public VertexPair edge() {
		return edge;
	}

	/**
	 * weight() returns the weight of "this" Edge.
	 * 
	 * @return the weight of "this" Edge.
	 */
	public int weight() {
		return weight;
	}

	/**
	 * toString() returns the String representaion of "this" Edge.
	 * [ edge  weight  ]
	 * 
	 * @return the String representaion of "this" Edge.
	 */
	public String toString() {
		return "[ " + edge + " " + weight + " ]";
	}

}
